<template>
  <svg class="svg-icon" aria-hidden="true" :style="cssVars">
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script>
export default {
  name: "IconSvg",
  props: {
    iconClass: {
      type: String,
      required: true,
    },
    size: {
      type: String,
      default: "1.5em",
    },
  },
  computed: {
    iconName() {
      return `#icon-${this.iconClass}`;
    },
    cssVars() {
      return {
        "--size": this.size,
      };
    },
  },
};
</script>

<style scoped>
.svg-icon {
  width: var(--size);
  height: var(--size);
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>
